import java.util.Arrays;

/**
 * @author wangj881
 * @date 2024-11-29 14:42
 */
public class L455_2 {

    public static void main(String[] args) {
        int[] g = {1, 2, 3};
        int[] s = {1, 1};
        new Solution().findContentChildren(g, s);

    }

    static class Solution {
        public int findContentChildren(int[] g, int[] s) {
            Arrays.sort(g);
            Arrays.sort(s);
            int result = 0;
            int tmp = 0;

            for (int i = 0; i < g.length; i++) {
                while (tmp < s.length) {
                    if (g[i] <= s[tmp]) {
                        tmp++;
                        result++;
                        break;
                    } else {
                        tmp++;
                    }
                }
            }
            return result;
        }
    }
}
